import { AxiosProxyConfig } from "axios"

const $ipcConstants = {
  ipcMessageId: 'ipc.message.id',
  getSystemDownloadDir: "ipc.getSystemDownloadDir",
  openFolderSelector: "ipc.openFolderSelector",
  openSaveDir: "ipc.openSaveDir",
  registerTask: "ipc.registerTask",
  taskStateUpdate: "ipc.onTaskStateUpdate",
  exitApp: "ipc.exitApp", 
  debug: "ipc.debug",
}

export type IpcMessage = {
  methodName: string,
  data: any,
  uuid: string
}

export type CompressTask = {
  path: string
  name: string
  size: number
  type: string
  id: string
  state: number // 0等待中 1上传中 2压缩中 3下载中 4完成 5错误
  progress: {
    upload: number, download: number
  }
  uploadResult?: TinifyUploadResult
  saveOptions: {saveDir: string, replaceOrigin: boolean, systemDownloadDir: string}
  proxy?: AxiosProxyConfig
  storeResult?: TinyPngStoreResult
  processResult?: TinyPngProcessResult
}

export type TinyPngStoreResult = {
  key: string,
  url: string,
  size: number
}

export type TinyPngProcessResult = {
	"key": string,
	"size": number,
	"type": string,
	"width": number,
	"height": number,
	"url": string
}

export type TinifyUploadResult = {
  input: { size: number, type: string },
  output: {
    size: number,
    type: string,
    width: number,
    height: number,
    ratio: number,
    url: string
  }
}

export default $ipcConstants